local bishou = fk.CreateSkill({
    name = "sj5__bishou",
  })
  
  Fk:loadTranslationTable{
    ["sj5__bishou"] = "愎守",
    [":sj5__bishou"] = "出牌阶段，若你的手牌上限大于0，你可以弃置一张牌并展示牌堆顶X张牌，使用其中点数不小于X的牌，若未使用牌多于使用牌，你本回合手牌上限-1。（X为弃置牌点数）",
  
    ["#sj5__bishou"] = "你可以弃置一张牌，根据此牌点数使用牌堆中的牌",
    ["#sj5__bishou-log"] = "%from 可以使用 %card",
  
    ["@sj5__bishou-turn"] = "愎守",
  
    ["$sj5__bishou1"] = "吾有一计，可致司马懿于死地。",
    ["$sj5__bishou2"] = "丞相勿忧，司马懿不足为患。",
  }
  
  bishou:addEffect("active", {
    prompt = "#sj5__bishou",
    can_use = function(self, player)
       return player:getMaxCards() > 0 and not player:isNude()
    end,
    card_filter = function (self, player, to_select, selected)
      return #selected == 0
    end,
    min_card_num = 1,
    max_card_num = 1,
    on_use = function(self, room, effect)
      local player = effect.from
      --room:notifySkillInvoked(player, bishou.name)
      local num = Fk:getCardById(effect.cards[1]).number--弃置牌点数
      room:throwCard(effect.cards,bishou.name,player,player)
      local cards = room:getNCards(num)
      room:moveCardTo(cards, Card.Processing, nil, fk.ReasonJustMove, bishou.name, nil, true, player)
      room:delay(#cards * 150)
      local cards_true = {}
      table.insertTable(cards_true,cards)
      local y = 0 --使用的牌数
        repeat
          cards_true = table.filter(cards_true,function(id)
            local tc = Fk:getCardById(id)
            return #tc:getDefaultTarget(player,{bypass_times = true}) > 0 and tc.number >= num end)
            --能主动用的牌,不小于弃置牌点数
          if #cards_true > 0 then
            if y == 0 then
              player.room:sendLog{
                type = "#sj5__bishou-log",
                from = player.id,
                card = cards_true,
                toast = true,}
            else
              player:broadcastSkillInvoke(bishou.name)
            end
            y = y + 1
            local x = room:askToUseRealCard(player,{
              pattern = cards_true,
              skill_name = bishou.name,
              extra_data = {expand_pile = cards_true},
              cancelable = false,
            })
            table.removeOne(cards_true,x.card.id)
          end
        until #cards_true == 0--真就下去，假就循环
      if (#cards - y) > y then
        room:addPlayerMark(player,MarkEnum.MinusMaxCardsInTurn)
      end
      cards = table.filter(cards, function(id) return room:getCardArea(id) == Card.Processing end)--还在处理区的牌
      room:moveCardTo(table.reverse(cards), Card.DrawPile, nil, fk.ReasonPut, bishou.name, nil, true, player)
    end,
  })

  return bishou